<template>
<div class="my-box">
     
</div>
</template>

<script>
export default {
    data() {
        return {
            timer: null
        }
    },
    created () {
        this.timer = setInterval( () => {
            console.log('我是给mybox用的定时器')
        }, 1000)
    },
    beforeDestroy() {
        console.log('beforeDestroy')
        
    },
    destroyed() {
        console.log('destroyed')
        // 就要在销毁的时候关了定时器
        clearInterval(this.timer)
    },
}
</script>

<style scoped>

.my-box {
    width: 350px;
    height: 370px;
    border: 1px solid #000;
}
</style>